package com.qcxy.gzy.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.Toast;

import com.qcxy.gzy.activity.base.HiddenActivity;
import com.qcxy.gzy.activity.base.HiddenAdaptiveActivity;
import com.qxcy.gzy.util.SPUtils;

public class LoginActivity extends HiddenAdaptiveActivity implements OnClickListener {

    private EditText mEditText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login_new);
        mEditText = findViewById(R.id.login_pwd);
        findViewById(R.id.iv_back).setOnClickListener(this);
        findViewById(R.id.iv_back_layout).setOnClickListener(this);
        findViewById(R.id.login_ok).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
            case R.id.iv_back_layout:
                Intent intent = new Intent(LoginActivity.this, MainActivity.class);
                startActivity(intent);
                LoginActivity.this.finish();
                break;
            case R.id.login_ok:
                String password = mEditText.getText().toString();
                if (SPUtils.getValueFromSharedFile(this, "password", "123456").equals(password)) {
                    Intent i = new Intent(LoginActivity.this, SettingActivity.class);
                    startActivity(i);
                    LoginActivity.this.finish();
                } else {
                    Toast.makeText(this, R.string.log_file, Toast.LENGTH_SHORT).show();
                }
                break;
            default:
                break;
        }
    }
}